import { ApiProperty, OmitType } from '@nestjs/swagger';
import { BlogEntity } from '../entities/blog.entity';
import {
  SearchDto,
  SearchReturn,
} from 'src/common/decorators/search.decorator';

export class ListBlogDto implements SearchDto {
  @ApiProperty({
    type: String,
    description: '页数',
    required: true,
    default: '1',
  })
  page: number;
  @ApiProperty({
    type: String,
    description: '每页分页数',
    required: true,
    default: '5',
  })
  pagesize: number;
}

class ListBlogItem extends OmitType(BlogEntity, ['content']) {}

export class ListBlogReturn implements SearchReturn {
  @ApiProperty()
  total: number;
  @ApiProperty({ type: ListBlogItem, isArray: true })
  rows: BlogEntity[];
  @ApiProperty()
  page: number;
  @ApiProperty()
  pagesize: number;
}
